﻿Public Class fSetBasic

    Private Sub btnOK_Click(sender As System.Object, e As System.EventArgs) Handles btnOK.Click
        'saves selections to string var in Settings:
        Dim str As String = Nothing
        For i As Integer = 0 To Me.trVSel.Nodes.Count() - 1
            If Me.trVSel.Nodes(i).Checked = True Then
                str = str & "1;"
            Else
                str = str & "0;"
            End If
        Next i
        My.Settings.setBasic = str.Trim
        My.Settings.Save()

        Me.DialogResult = Windows.Forms.DialogResult.OK

    End Sub

    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub fSetBasic_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.Dispose()
    End Sub

    Private Sub fSetBasic_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If My.Settings.firstRun = False Then
            Dim setVals() As String = My.Settings.setBasic.Trim.Split(";")
            For i As Integer = 0 To Me.trVSel.Nodes.Count() - 1
                If setVals(i) = "1" Then
                    Me.trVSel.Nodes(i).Checked = True
                Else
                    Me.trVSel.Nodes(i).Checked = False
                End If
            Next i
        End If
    End Sub
End Class